package com.sti.platform.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aisino.core.common.JsonPost;
import com.aisino.core.controller.BaseController;
import com.aisino.tools.util.WebConstants;
import com.sti.platform.service.BackupService;


/*
 * 有关数据库的备份和恢复
 */
@SuppressWarnings("rawtypes")
@Controller()
@RequestMapping("backup")
public class BackupController extends BaseController {
	
	@Autowired
	private BackupService backupService;

	
	@RequestMapping("index")
	public String index(){
		return "index";
	}
	
	
	
	@RequestMapping("add")
	public @ResponseBody Map add(final String type){
		return super.jsonPost(new JsonPost() {
			@SuppressWarnings("unchecked")
			@Override
			public void doInstancePost(Map arg0) {
				arg0.put(WebConstants.JSON_MESSAGE, backupService.add(type));
			}
		});
	}
	
	@RequestMapping("recovery")
	public @ResponseBody Map recovery(){
		return super.jsonPost(new JsonPost() {
			@SuppressWarnings("unchecked")
			@Override
			public void doInstancePost(Map arg0) {
				arg0.put(WebConstants.JSON_MESSAGE, backupService.reovery());
			}
		});
	}
	
	
}
